home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / CoreGateway / LetterLogWindow.cp < prev    next >
Encoding:
Text File  |  1995-07-28  |  2.7 KB  |  130 lines  |  [TEXT/R*ch]

  1. /*
  2.     File:        LetterLogWindow.cp
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef __LETTERLOGWINDOW__
  15. #include "LetterLogWindow.h"
  16. #endif
  17.  
  18. #ifndef __FONTS__
  19. #include "FONTS.h"
  20. #endif
  21.  
  22. #ifndef __MENUS__
  23. #include <Menus.h>
  24. #endif
  25.  
  26. #ifndef __GRAFPORTSAVER__
  27. #include "GrafPortSaver.h"
  28. #endif
  29.  
  30. #ifndef __LETTERLOG__
  31. #include "LetterLog.h"
  32. #endif
  33.  
  34. #ifndef __OBJECTLIST__
  35. #include "ObjectList.h"
  36. #endif
  37.  
  38. #ifndef __TYPES__
  39. #include <Types.h>
  40. #endif
  41.  
  42. #ifndef __WINDOWS__
  43. #include <Windows.h>
  44. #endif
  45.  
  46. /***********************************|****************************************/
  47.  
  48. TLetterLogWindow::TLetterLogWindow ( TLetterLog* log, short windowID ) :
  49.     TLogWindow ( windowID ),
  50.     fLog ( log )
  51. {
  52. }
  53.  
  54. /***********************************|****************************************/
  55.  
  56. TLetterLogWindow::~TLetterLogWindow ( )
  57. {
  58. }
  59. /***********************************|****************************************/
  60.  
  61. void TLetterLogWindow::Draw ( ) const
  62. {
  63.     if ( GetWindowPtr() ) 
  64.         Draw (  GetWindowPtr()->portRect );
  65. }
  66.  
  67. /***********************************|****************************************/
  68.  
  69.  
  70. void TLetterLogWindow::Draw( const Rect& drawRect ) const
  71. {    
  72.     if ( GetWindowPtr() )
  73.     {    CGrafPortSaver saved ( GetWindowPtr () );
  74.         Boolean drewARow = false;
  75.         
  76.         unsigned long count = GetRowCount ();
  77.         for ( unsigned long index = ( drawRect.top / fHeight ) - 1; index <= count ; ++ index )
  78.         {    Rect r = GetRectForRow ( index );
  79.  
  80.             if ( ( r.bottom >= drawRect.top ) && ( r.top <= drawRect.bottom ) )
  81.             {
  82.                 DrawRow ( index );
  83.                 drewARow = true;
  84.             }
  85.             else if ( drewARow )
  86.                 break;
  87.         }
  88.     }
  89. }
  90.  
  91. /***********************************|****************************************/
  92.  
  93. void TLetterLogWindow::DrawRow ( unsigned long whichRow ) const
  94. {
  95.     CGrafPortSaver saved ( GetWindowPtr () );
  96.     TLetterLogEnumerator items ( *fLog );
  97.     
  98.     if ( ( whichRow >= 1 ) && ( whichRow <= items.CountEntries() ) )
  99.     {
  100.         const TLetterLogEntry* entry = items.GetEntryByIndex ( whichRow );
  101.         
  102.         Rect r = GetRectForRow ( whichRow );
  103.         
  104.         if ( entry )
  105.         {
  106.             DrawString ( r.left + 2, r.bottom - 2, entry->fSubject );
  107.             EraseLineTo ( r.left + 120, r.bottom - 2 );
  108.             DrawString ( r.left + 120, r.bottom - 2, entry->fSender );
  109.             
  110.         }
  111.     }
  112. }
  113.  
  114. /***********************************|****************************************/
  115.  
  116. unsigned long TLetterLogWindow::GetRowCount ( ) const
  117. {
  118.     TLetterLogEnumerator items ( *fLog );
  119.     return items.CountEntries();
  120. }
  121.  
  122. /***********************************|****************************************/
  123.  
  124. unsigned long TLetterLogWindow::GetRowWidth ( ) const
  125. {
  126.     return 200;
  127. }
  128.  
  129. /***********************************|****************************************/
  130.